package com.microservice.base.task;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.json.JSONException;

import java.math.BigInteger;

/**
 * @author jbx
 * @package_name com.microservice.base.task
 * @create_date 2020/12/12 9:53
 */
public class TestHik {
  public static void main(String[] args) throws JSONException {
    //        JSONArray jsonArray = new JSONArray();
    //        JSONObject jo = new JSONObject();
    //        jo.put("personName", "person0");
    //        jo.put("personId", "111");
    //        jo.put("orgIndexCode", "root000000");
    //        jo.put("certificateType", "111");
    //        jo.put("certificateNo", "370785199712156019");
    //        jo.put("gender", 1);
    //        jsonArray.add(jo);
    //        System.out.println(jsonArray);
    //        HikConnection.pushHik("/api/resource/v1/person/batch/add", jsonArray.toString());

    //    JSONObject jo1 = new JSONObject();
    //    jo1.put("pageNo", "1");
    //    jo1.put("resourceType", "region");
    //    jo1.put("pageSize", "1000");
    //    String s = HikConnection.pushHik("/api/irds/v2/region/nodesByParams", jo1.toString());
    //    JSONObject jsonObject = JSONObject.parseObject(s);
    //    JSONObject data = jsonObject.getJSONObject("data");
    //    System.out.println(data);
    //    int total = data.getInteger("total");
    //    System.out.println(total);
    //    List<CHkRegion> list = data.getJSONArray("list").toJavaList(CHkRegion.class);
    //    System.out.println(list);
    //    System.out.println(jsonObject.getString("code"));
    //    System.out.println(jsonObject.getString("msg"));

    //    JSONObject jo = new JSONObject();
    //    String[] strings = new String[9];
    //    strings[0] = "45c9ab04d87f40d39cc1f8272a1a6c4b";
    //    strings[3] = "f6df71aa5ecc452890964a4485fe7d23";
    //    strings[4] = "882e6fa7b67c4a39b3dce5b6a17c00d4";
    //    strings[5] = "e45beffa7527419ea4c77950b5e571c1";
    //    strings[6] = "11b6ed17f62d48a2ada09e6d88ca9dd9";
    //    strings[7] = "29a3dc78f48e44fd82877b23150e6f71";
    //    jo.put("indexCodes", strings);
    //    System.out.println(jo);
    //    HikConnection.pushHik("/api/resource/v1/org/batch/delete", jo.toString());

    //    JSONObject jo1 = new JSONObject();
    //    SimpleDateFormat simpleDateFormat = new
    // SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS+8:00");
    //    Date now = new Date();
    //    Date afterDate = new Date(now.getTime() + 600000);
    //    System.out.println(simpleDateFormat.format(now));
    //    System.out.println(simpleDateFormat.format(afterDate));
    //    // 真正开始的时候starttime是数据库最大时间
    //    jo1.put("startTime", simpleDateFormat.format(now));
    //    // 结束时间是当前系统时间
    //    jo1.put("endTime", simpleDateFormat.format(afterDate));
    //    jo1.put("similarity", 80);
    //    String s = HikConnection.pushHik("/api/frs/v1/event/black/search", jo1.toString());
    //    JSONObject jsonObject = JSONObject.parseObject(s);
    //    JSONObject data = jsonObject.getJSONObject("data");
    //    System.out.println(data);
    //      }
    //    Calendar calendar= Calendar.getInstance();
    //    calendar.set(2020, 11, 01);
    //    Date date = calendar.getTime();
    //    System.out.println(date);
    //    String s =
    //        "{\n"
    //            + "    \"code\": \"0\",\n"
    //            + "    \"msg\": \"Success\",\n"
    //            + "    \"data\": {\n"
    //            + "        \"total\": 500,\n"
    //            + "        \"pageNo\": 1,\n"
    //            + "        \"pageSize\": 20,\n"
    //            + "        \"list\": [\n"
    //            + "            {\n"
    //            + "                \"snapInfo\": {\n"
    //            + "                    \"bkgUrl\":
    // \"http://10.19.132.9:6040/pic?=d3=0dpi*=1d7i3t1pe*m5i14=89ba-28zad1s=439cd1\",\n"
    //            + "                    \"snapUrl\":
    // \"http://10.19.132.9:6040/pic?=d72i794e*9dbi99b-a24aeb--193f24c8ifb1*=sd*pe*m5i14=89ba-28zad1s=337cd3\",\n"
    //            + "                    \"deviceIndexcode\":
    // \"e973dc5f76c443c2ad6f404b679d39d5\",\n"
    //            + "                    \"deviceName\": \"设备名称\",\n"
    //            + "                    \"cameraIndexcode\":
    // \"282c954b564045a59353f6441bbbbf76\",\n"
    //            + "                    \"cameraName\": \"监控点名称\",\n"
    //            + "                    \"gender\": \"male\",\n"
    //            + "                    \"age\": \"young\\t\",\n"
    //            + "                    \"glass\": \"yes\",\n"
    //            + "                    \"eventTime\": \"2018-07-26T15:00:00.000+08:00\"\n"
    //            + "                },\n"
    //            + "                \"targetInfoList\": [\n"
    //            + "                    {\n"
    //            + "                        \"name\": \"张三\",\n"
    //            + "                        \"similarity\": \"6\",\n"
    //            + "                        \"certificateType\": \"ID\",\n"
    //            + "                        \"sex\": \"male\",\n"
    //            + "                        \"certificateNumber\": \"1234567890\",\n"
    //            + "                        \"faceInfoIndexcode\":
    // \"624cfb31-16bd-4747-afb1-a9468ff9a441\",\n"
    //            + "                        \"faceGroupIndexcode\":
    // \"e8997392-a969-429c-acee-8879d6eff3b1\",\n"
    //            + "                        \"faceGroupName\": \"人脸分组名称\",\n"
    //            + "                        \"faceUrl\":
    // \"http://10.33.47.14:6120/pic?8dd195ic3-e*9da4818ab115m4ep=t =d1s*i=d1b*i8d4d*8af2fc914-
    // -03ebd05zb97s=8i94=\"\n"
    //            + "                    }\n"
    //            + "                ]\n"
    //            + "            }\n"
    //            + "        ]\n"
    //            + "    }\n"
    //            + "}\n";
    //    JSONObject jsonObject = JSONObject.parseObject(s);
    //    JSONObject data = jsonObject.getJSONObject("data");
    //    List<CHkRecords> saveList = new ArrayList<>();
    //    int total = data.getInteger("total");
    //    JSONArray recordslist = data.getJSONArray("list");
    //    JSONObject jsonObject1 = recordslist.getJSONObject(0);
    //    JSONObject snapInfo = jsonObject1.getJSONObject("snapInfo");
    //    List<TargetInfo> targetInfoList =
    //        jsonObject1.getJSONArray("targetInfoList").toJavaList(TargetInfo.class);
    //    System.out.println(snapInfo.get("bkgUrl"));
    //    for (TargetInfo targetInfo : targetInfoList) {
    //      System.out.println(targetInfo.getCertificateNumber());
    //      System.out.println(targetInfo.getSex());
    //      System.out.println(targetInfo.getCertificateType());
    //      System.out.println(targetInfo.getSimilarity());
    //      System.out.println(targetInfo.getName());
    //      System.out.println(targetInfo.getFaceUrl());
    //      System.out.println(targetInfo.getFaceInfoIndexcode());
    //    }
//
    com.alibaba.fastjson.JSONObject total = new JSONObject();
    JSONArray jsonArray = new JSONArray();
    JSONObject jo = new JSONObject();
    jo.put("cardNo",new BigInteger("A015DFB2",16).toString() );
    jo.put("personId", "ddcaef110dd84c10acbca2d81258acea");
    jo.put("orgIndexCode", "033227523f9944e09c3eda01bc651303");
    jsonArray.add(jo);
    total.put("cardList", jsonArray);
    total.put("startDate","2020-12-12");
    total.put("endDate","2020-12-30");
    String s = HikConnection.pushHik("/api/cis/v1/card/bindings", total.toString());
    System.out.println(s);
  }
}
